<template>
  <Transition name="dAction">
    <div class="detailWraper" v-if="detailPopupsShow">
      <div class="top">
        <div class="topBtn">
          <p>联系墙主撕掉标签</p>
          <p>举报</p>
        </div>
        <i class="iconfont icon-guanbi" @click="detailIsShow()"></i>
      </div>
      <div class="card" :style="{ backgroundColor: 'orange' }">
        <div class="cardTop">
          <p>2022.12.30</p>
          <p>{{ labelData[cardData.label] }}</p>
        </div>
        <div class="cardCentent">
          <p>{{ cardData.message }}</p>
        </div>
        <div class="cardFooter">
          <div class="cardFooterLeft">
            <span class="iconfont icon-xiai"></span>
            <i>{{ cardData.like }}</i>
            <span class="iconfont icon-liuyan"></span>
            <i>{{ cardData.revoke }}</i>
          </div>
          <p>{{ cardData.name }}</p>
        </div>
      </div>
      <div class="commentIn">
        <textarea rows="3" placeholder="请输入..."></textarea>
        <div class="commentSignature">
          <input type="text" placeholder="匿名">
          <el-button type="info" round>确定</el-button>
        </div>
      </div>
      <div class="commentOut">
        <div class="commentOutTop">
          <p>评论</p>
          <p>{{ cardData.revoke }}</p>
        </div>
        <div class="commentOutContent" v-for="(msg, index) in comment.data" :key="msg.id">
          <div class="commentOutContentTop">
            <span :style="{ backgroundColor: cartColor1[index] }"></span>
            <p>匿名</p>
            <p>2022.12.31</p>
          </div>
          <p class="commentOutContentNr">{{ msg.message }}</p>
        </div>
      </div>
    </div>
  </Transition>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { storeToRefs } from 'pinia';

import { useMainStore } from '../store';
import { lable } from '../assets/data/wall'
import { comment } from '../mock/index'
import { cartColor1 } from '../assets/data/wall'

const mainStore = useMainStore()
const { detailPopupsShow, cardData, index } = storeToRefs(mainStore)
const { upDetailPopups } = mainStore

const labelData = lable[index.value]

// 关闭弹出层
const detailIsShow = () => {
  upDetailPopups()
}

</script>

<style lang="scss" scoped>
.dAction {
  &-enter {
    &-from {
      transform: translateX(300px);
    }

    &-active {
      transition: .4s ease-in;
    }

    &-to {
      transform: translateX(0);
    }
  }

  &-leave {
    &-from {
      transform: translateX(0);
    }

    &-active {
      transition: .4s ease-out;
    }

    &-to {
      transform: translateX(300px);
    }
  }

}

.detailWraper {
  width: 300px;
  height: 100%;
  box-sizing: border-box;
  background-color: rgba(255, 255, 255, 1);
  z-index: 998;
  backdrop-filter: blud(80px);
  position: fixed;
  top: 50px;
  right: 0;

  .top {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid orange;

    .topBtn {
      display: flex;

      p {
        margin-right: 10px;
        font-size: 14px;
        cursor: pointer;
      }

      &>p:first-child {
        color: rgb(2, 130, 222);
      }

      &>p:last-child {
        color: rgb(255, 81, 0);
      }
    }

    i {
      font-size: 20px;
      color: rgb(133, 144, 143);
      cursor: pointer;
    }
  }

  .card {
    width: 94%;
    height: 180px;
    border: 1px solid orange;
    box-sizing: border-box;
    padding: 10px;
    margin: 0 auto;
    margin-top: 5px;

    .cardTop {
      font-size: 13px;
      color: rgb(132, 132, 132);
      display: flex;
      justify-content: space-between;
      padding-bottom: 5px;
      cursor: pointer;
    }

    .cardCentent {
      width: 100%;
      height: calc(180px - 70px);
      box-sizing: border-box;
      padding: 5px 5px 0 10px;
      overflow-y: auto;
      font-size: 16px;
      font-family: '楷体';

      &::-webkit-scrollbar {
        width: 4px;
        height: 2px;
      }

      &::-webkit-scrollbar-thumb {
        border-radius: 5px;
        background-color: rgba(0, 0, 0, .5);
      }

      &::-webkit-scrollbar-track {
        border-radius: 5px;
        background-color: rgba(0, 0, 0, 0);
      }
    }

    .cardFooter {
      width: 100%;
      display: flex;
      justify-content: space-between;
      margin-top: 5px;

      .cardFooterLeft {
        display: flex;
        font-size: 14px;

        &>i:first-of-type {
          display: block;
          margin-right: 10px;
        }
      }
    }
  }

  .commentIn {
    width: 94%;
    margin: 0 auto;
    padding: 10px 0 5px 0;

    textarea {
      width: 100%;
      padding: 5px;
      box-sizing: border-box;
      resize: none;
      border: 2px solid rgb(0, 194, 129);
      border-radius: 6px;
    }

    .commentSignature {
      display: flex;
      justify-content: space-between;
      margin-top: 6px;

      input {
        border: 2px solid rgb(0, 194, 129);
        box-sizing: border-box;
        padding: 5px;
        border-radius: 10px;
        font-size: 12px;
      }
    }
  }

  .commentOut {
    width: 94%;
    height: 300px;
    margin: 0 auto;
    border: 1px solid orange;
    box-sizing: border-box;
    padding: 10px 0 0 0;
    overflow-x: hidden;
    overflow-y: auto;

    &::-webkit-scrollbar {
      width: 4px;
      height: 2px;
    }

    &::-webkit-scrollbar-thumb {
      border-radius: 5px;
      background-color: rgba(0, 0, 0, .5);
    }

    &::-webkit-scrollbar-track {
      border-radius: 5px;
      background-color: rgba(0, 0, 0, 0);
    }

    .commentOutTop {
      display: flex;
      margin-bottom: 10px;

      &>p:first-child {
        margin-right: 10px;
        font-size: 16px;
        font-weight: 600;
      }
    }

    .commentOutContent {
      width: 100%;
      overflow-y: auto;

      .commentOutContentTop {
        width: 100%;
        display: flex;
        font-size: 14px;
        line-height: 30px;

        span {
          width: 26px;
          height: 26px;
          border-radius: 50%;
          margin-right: 10px;
        }

        p {
          font-size: 14px;
          color: rgb(112, 112, 112);

          &:first-of-type {
            font-weight: 600;
            margin-right: 10px;
          }

          &:last-of-type {
            font-size: 12px;
          }
        }
      }

      .commentOutContentNr {
        padding: 0px 0 16px 16px;
        font-size: 13px;

      }
    }
  }
}
</style>